/**
 * 
 */
package crawler;

import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import javax.imageio.ImageIO;

/**
 * @author bliu
 *
 */
public class ImageDownload {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			URL url = new URL("http://img1.gtimg.com/news/pics/hv1/202/16/1363/88633357.jpg");
			BufferedInputStream in = new BufferedInputStream(url.openStream());

			FileOutputStream fileOutputStream = new FileOutputStream(new File("c:/tmp/test.jpg"));
			BufferedOutputStream out = new BufferedOutputStream(fileOutputStream);
			BufferedImage imagetem = ImageIO.read(in);
			ImageIO.write(imagetem, "jpg", out);
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}
